Google Account
neeraj vijay
neerajvijayiitb1201@gmail.com
Code
Insert code cell below
Ctrl+M B
Text
Add text cell
Copy to Drive
Notebook
Code Text

Task : Session 1

Solve these questions own your own and try to test yourself what you have learned in the session.

Happy Learning!

Code Text

Q1 :- Print the given strings as per stated format.

Given strings:

"Data" "Science" "Mentorship" "Program" 
"By" "CampusX"

Output:

Data-Science-Mentorship-Program-started-By-CampusX

Concept- [Seperator and End]

Code Text

print("Data","-""Science","-""Mentorship","-""Program","-""By","-""CampusX")
Data - Science - Mentorship - Program - By - CampusX
Code Text

Q2:- Write a program that will convert celsius value to fahrenheit.

Code Text

C=float(input("enter value of degree celsius"))
F=(9/5)*C+32
print("The value of Fahrenheit is equal",F)
enter value of degree celsius23
The value of Fahrenheit is equal 73.4
Code Text

ψ

Q3:- Take 2 numbers as input from the user.Write a program to swap the numbers without using any special python syntax.

Code Text

enter a :1
enter b :2
The value of a is 2
The value of b is 1
Code Text

ψ

Q4:- Write a program to find the euclidean distance between two coordinates.Take both the coordinates from the user as input.

Code Text

x1=int(input("enter value of x1="))
x2=int(input("enter value of x2="))
y1=int(input("enter value of y1="))
y2=int(input("enter value of y2="))
distance=((x2-x1)**2+(y2-y1)**2)**0.5
print(" eucleidian distance is equal to",distance)
enter value of x1=1
enter value of x2=2
enter value of y1=3
enter value of y2=5
 eucleidian distance is equal to 2.23606797749979
Code Text

ψ

Q5:- Write a program to find the simple interest when the value of principle,rate of interest and time period is provided by the user.

Code Text

ψ

Double-click (or enter) to edit

Code Text

p=int(input("enter value of priciple amount="))
r=int(input("enter value of rate of interest="))
t=int(input("enter value of time period="))
SI=(p*r*t)/100
print("The simple interest value is equal to",SI)
enter value of priciple amount=50000
enter value of rate of interest=5
enter value of time period=5
The simple interest value is equal to 12500.0
Code Text

ψ

Q6:- Write a program that will tell the number of dogs and chicken are there when the user will provide the value of total heads and legs.

For example: Input: heads -> 4 legs -> 12
Output: dogs -> 2 chicken -> 2

Code Text

enter value of heads=4
enter value of legs=12
number of chickens is equal to  2
number of dogs is equal to  2
Code Text

ψ

Q7:- Write a program to find the sum of squares of first n natural numbers where n will be provided by the user.

Code Text

n=int(input("enter value of n ="))
sum_number= n*(n+1)*(2*n+1)/6
print("The sum of squares of first n natural number is",int(sum_number))
enter value of n =5
The sum of squares of first n natural number is 55
Code Text

ψ

Q8:- Given the first 2 terms of an Arithmetic Series.Find the Nth term of the series. Assume all inputs are provided by the user.

Code Text

a1=int(input("enter first term a1 ="))
a2=int(input("enter first term a2="))
n=int(input("enter value of number of terms n ="))
d=a2-a1
an=a+(n-1)*d
print("The nth term of series is equal to",int(an))
enter first term a1 =2
enter first term a2=5
enter value of number of terms n =23
The nth term of series is equal to 68
Code Text

ψ

Q9:- Given 2 fractions, find the sum of those 2 fractions.Take the numerator and denominator values of the fractions from the user.

Code Text

from re import S
num_1=int(input("enter first numerator value ="))
num_2=int(input("enter second numerator value ="))
deno_1=int(input("enter first denominator value ="))
deno_2=int(input("enter first denominator value ="))
summation=(num_1/deno_1)+(num_2/deno_2)
print("The sum of two fraction is equal to ",float(summation))

enter first numerator value =1
enter second numerator value =2
enter first denominator value =5
enter first denominator value =2
The sum of two fraction is equal to  1.2
Code Text

ψ

Q10:- Given the height, width and breadth of a milk tank, you have to find out how many glasses of milk can be obtained? Assume all the inputs are provided by the user.

Input:
Dimensions of the milk tank
H = 20cm, L = 20cm, B = 20cm

Dimensions of the glass
h = 3cm, r = 1cm

Code Text

# dimension for tank
H=int(input("enter value of height(cm) ="))
L=int(input("enter value of length(cm) ="))
B=int(input("enter value of breath(cm) ="))
Vol_tank=L*B*H
print("The total volume of milk in tank(cm3)",Vol_tank)
# dimension for glass its cylinderical shape
h=int(input("enter value of height of glass(cm) ="))
r=int(input("enter value of radius of glass(cm) ="))
Vol_glass=3.14*(r**2)*h
print("The volume(cm3) of glass of milk is equal to",Vol_glass)
num_glass= Vol_tank/Vol_glass
print("the number of glass of milk is equal to",int(num_glass))
enter value of height(cm) =20
enter value of length(cm) =20
enter value of breath(cm) =20
The total volume of milk in tank(cm3) 8000
enter value of height of glass(cm) =3
enter value of radius of glass(cm) =1
The volume(cm3) of glass of milk is equal to 9.42
the number of glass of milk is equal to 849
Code Text

Code Text